public class day12 {

    public static void main(String[] args) {


        int[][]arr=new int[11][11];
        arr[1][2]=1;
        arr[2][3]=2;
        arr[4][5]=1;

        int count =0;
        for (int i = 0; i <arr.length ; i++) {
            for (int j = 0; j < arr[i].length; j++) {
                if (arr[i][j]!=0){
                    count++;
                }
                System.out.print(arr[i][j]+"  |");
            }
            System.out.println();
        }

        int[][] brr = new int[count +1][3];
        brr[0][0]=11;
        brr[0][1]=11;
        brr[0][2]=count;
        int intof=1;

        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j <arr[i].length; j++) {
               if (arr[i][j]!=0){
                   brr[intof][0]=arr[i][j];
                   brr[intof][1]=i;
                   brr[intof][2]=j;
                   intof++;
               }
            }
        }



        for (int i = 0; i <brr.length ; i++) {
            for (int j = 0; j < brr[i].length; j++) {
                System.out.print(brr[i][j]+"  |");
            }
            System.out.println();
        }


        int[][] crr = new int[brr[0][0]][brr[0][1]];
        for (int i = 1; i < brr.length; i++) {
            for (int j = 0; j <brr[i].length; j++) {
                crr[brr[i][1]][brr[i][2]]=brr[i][0];
            }
        }

        for (int i = 0; i <crr.length ; i++) {
            for (int j = 0; j < crr[i].length; j++) {
                System.out.print(crr[i][j]+"  |");
            }
            System.out.println();
        }
    }
}
